package com.hfut.manage.controller;


import com.hfut.manage.pojo.Result;
import com.hfut.manage.pojo.RewardPunishment;
import com.hfut.manage.service.IRewardPunishmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zwh
 * @since 2025-06-03
 */
@RestController
@RequestMapping("/reward-punishment")
public class RewardPunishmentController {

    @Autowired
    private IRewardPunishmentService rewardPunishmentService;

    @PostMapping
    public Result save(@RequestBody RewardPunishment rewardPunishment) {
        rewardPunishmentService.save(rewardPunishment);
        return Result.success();
    }

    @GetMapping
    public Result getById(@RequestParam Long teacherId) {
        List<RewardPunishment> rewardPunishments = rewardPunishmentService.lambdaQuery()
                .eq(RewardPunishment::getTeacherId, teacherId)
                .list();
        return Result.success(rewardPunishments);
    }
}
